package com.yuhanginfo.modules.web.web;

import org.apache.shiro.authz.UnauthenticatedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.context.request.NativeWebRequest;

import com.yuhanginfo.common.web.BaseController;

/**
 * 异常控制
 * @author yinhao
 * @version 2017-11-6
 */
@ControllerAdvice  
public class WebExceptionController extends BaseController{

	
	@ExceptionHandler(UnauthenticatedException.class)
	public String processUnauthenticatedException(NativeWebRequest request,UnauthenticatedException e) {
		String str = request.toString();
		String uri = str.substring(str.indexOf("uri=")+4,str.indexOf(';'));
		if(uri.contains("userCenter/mobile")){
			return "modules/web/webLogin";
		}else{
			return "redirect:"+ frontPath +"/webIndex";
		}
		
	}

}